package com.zzq.controller;

import com.zzq.domain.entity.SmileCouponRule;
import com.zzq.domain.search.CouponRuleSerachParamet;
import com.zzq.result.SmileResult;
import com.zzq.service.CouponRuleAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/admin/coupon/rule")
@RestController
@Api(value = "票卷规则管理",tags = {"票卷规则管理"})
public class CouponRuleAdminController {

    @Autowired
    CouponRuleAdminService couponRuleAdminService;
    @PostMapping("/list")
    @ApiOperation("获取规则列表")
    public SmileResult list(@RequestBody CouponRuleSerachParamet serachParamet){
       return couponRuleAdminService.getCouponRuleDTOList(serachParamet);
    }

    @PostMapping("/add")
    @ApiOperation("添加规则列表")
    public SmileResult list(@RequestBody SmileCouponRule couponRule){
        return couponRuleAdminService.addCouponRule(couponRule);
    }

    @PostMapping("/upd")
    @ApiOperation("更新规则列表")
    public SmileResult upd(@RequestBody SmileCouponRule couponRule){
        return couponRuleAdminService.updCouponRule(couponRule);
    }

    @GetMapping ("/del")
    @ApiOperation("删除规则列表")
    public SmileResult upd(@RequestParam("couponRuleId") Long couponRuleId){
        return couponRuleAdminService.delCouponRule(couponRuleId);
    }
}
